package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "business_info", schema = "springboot", catalog = "")
public class BusinessInfo {
    private int businesId;//商机id
    private String businessName;//商机名称
    private BigDecimal expectedAmount;//预期金额
    private Timestamp updateTime;//更新时间
    private Date estimatedSigningTime;//预计签约
    private String businessRemarks;//备注
    private Timestamp businessTime;//商机创建时间
    private Integer opportunityStatus;//商机状态
    private Customer customerByCustomId;//客户对象
    private Culinkman culinkmanByCupId;//客户联系人对象
    private SpeedInfo speedInfoBySpeedId;//进度对象
    private Collection<Competitor> competitorsByBusinesId;
    private Collection<Contract> contractsByBusinesId;
    private Collection<Demand> demandsByBusinesId;
    private List<Details> detailsByBusinesId;
    private Collection<FollowUp> followUpsByBusinesId;
    private Collection<Offer> offersByBusinesId;
    private Collection<Programme> programmesByBusinesId;
    private Emp  budinessEmpid;//负责人
    private String status;//状态
    private int specialAttention;//是否特别关注

    @ManyToOne
    @JoinColumn(name = "budiness_empid", referencedColumnName = "employees_id")
    public Emp getBudinessEmpid() {
        return budinessEmpid;
    }

    public void setBudinessEmpid(Emp budinessEmpid) {
        this.budinessEmpid = budinessEmpid;
    }

    @Id
    @Column(name = "busines_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getBusinesId() {
        return businesId;
    }

    public void setBusinesId(int businesId) {
        this.businesId = businesId;
    }

    @Basic
    @Column(name = "business_name")
    public String getBusinessName() {
        return businessName;
    }

    public void setBusinessName(String businessName) {
        this.businessName = businessName;
    }

    @Basic
    @Column(name = "expected_amount")
    public BigDecimal getExpectedAmount() {
        return expectedAmount;
    }

    public void setExpectedAmount(BigDecimal expectedAmount) {
        this.expectedAmount = expectedAmount;
    }

    @Basic
    @Column(name = "update_time")
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }


    @Basic
    @Column(name = "estimated_signing_time")
    public Date getEstimatedSigningTime() {
        return estimatedSigningTime;
    }

    public void setEstimatedSigningTime(Date estimatedSigningTime) {
        this.estimatedSigningTime = estimatedSigningTime;
    }

    @Basic
    @Column(name = "business_remarks")
    public String getBusinessRemarks() {
        return businessRemarks;
    }

    public void setBusinessRemarks(String businessRemarks) {
        this.businessRemarks = businessRemarks;
    }

    @Basic
    @Column(name = "business_time")
    public Timestamp getBusinessTime() {
        return businessTime;
    }

    public void setBusinessTime(Timestamp businessTime) {
        this.businessTime = businessTime;
    }


    @Basic
    @Column(name = "opportunity_status")
    public Integer getOpportunityStatus() {
        return opportunityStatus;
    }

    public void setOpportunityStatus(Integer opportunityStatus) {
        this.opportunityStatus = opportunityStatus;
    }

    @Basic
    @Column(name = "status")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Basic
    @Column(name = "special_attention")
    public int getSpecialAttention() {
        return specialAttention;
    }

    public void setSpecialAttention(int specialAttention) {
        this.specialAttention = specialAttention;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BusinessInfo that = (BusinessInfo) o;
        return businesId == that.businesId &&
                Objects.equals(businessName, that.businessName) &&
                Objects.equals(expectedAmount, that.expectedAmount) &&
                Objects.equals(estimatedSigningTime, that.estimatedSigningTime) &&
                Objects.equals(businessRemarks, that.businessRemarks) &&
                Objects.equals(businessTime, that.businessTime);
    }


    @ManyToOne
    @JoinColumn(name = "custom_id", referencedColumnName = "custom_id")
    public Customer getCustomerByCustomId() {
        return customerByCustomId;
    }

    public void setCustomerByCustomId(Customer customerByCustomId) {
        this.customerByCustomId = customerByCustomId;
    }

    @ManyToOne
    @JoinColumn(name = "cup_id", referencedColumnName = "cup_id")
    public Culinkman getCulinkmanByCupId() {
        return culinkmanByCupId;
    }

    public void setCulinkmanByCupId(Culinkman culinkmanByCupId) {
        this.culinkmanByCupId = culinkmanByCupId;
    }

    @ManyToOne
    @JoinColumn(name = "speed_id", referencedColumnName = "speed_id")
    public SpeedInfo getSpeedInfoBySpeedId() {
        return speedInfoBySpeedId;
    }

    public void setSpeedInfoBySpeedId(SpeedInfo speedInfoBySpeedId) {
        this.speedInfoBySpeedId = speedInfoBySpeedId;
    }

    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public Collection<Competitor> getCompetitorsByBusinesId() {
        return competitorsByBusinesId;
    }

    public void setCompetitorsByBusinesId(Collection<Competitor> competitorsByBusinesId) {
        this.competitorsByBusinesId = competitorsByBusinesId;
    }

    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public Collection<Contract> getContractsByBusinesId() {
        return contractsByBusinesId;
    }

    public void setContractsByBusinesId(Collection<Contract> contractsByBusinesId) {
        this.contractsByBusinesId = contractsByBusinesId;
    }

    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public Collection<Demand> getDemandsByBusinesId() {
        return demandsByBusinesId;
    }

    public void setDemandsByBusinesId(Collection<Demand> demandsByBusinesId) {
        this.demandsByBusinesId = demandsByBusinesId;
    }



    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public List<Details> getDetailsByBusinesId() {
        return detailsByBusinesId;
    }

    public void setDetailsByBusinesId(List<Details> detailsByBusinesId) {
        this.detailsByBusinesId = detailsByBusinesId;
    }

    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public Collection<FollowUp> getFollowUpsByBusinesId() {
        return followUpsByBusinesId;
    }

    public void setFollowUpsByBusinesId(Collection<FollowUp> followUpsByBusinesId) {
        this.followUpsByBusinesId = followUpsByBusinesId;
    }

    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public Collection<Offer> getOffersByBusinesId() {
        return offersByBusinesId;
    }

    public void setOffersByBusinesId(Collection<Offer> offersByBusinesId) {
        this.offersByBusinesId = offersByBusinesId;
    }

    @OneToMany(mappedBy = "businessInfoByBusinesId")
    public Collection<Programme> getProgrammesByBusinesId() {
        return programmesByBusinesId;
    }

    public void setProgrammesByBusinesId(Collection<Programme> programmesByBusinesId) {
        this.programmesByBusinesId = programmesByBusinesId;
    }


}
